package com.fwmagic.dao;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update;
import org.springframework.stereotype.Repository;

import com.fwmagic.pojo.Notice;
import com.mongodb.WriteResult;

@Repository
public class NoticeDAO implements BaseDAO<Notice>{

	@Autowired
	private MongoTemplate mt;
	
	@Override
	public List<Notice> list(Query query, Class<Notice> entityClass) {
		return mt.find(query, entityClass);
	}

	@Override
	public Notice findOne(Query query, Class<Notice> entityClass) {
		return mt.findOne(query, entityClass);
	}
	
	@Override
	public void insert(Notice notice){
		mt.insert(notice);
	}
	
	@Override
	public WriteResult update(Query query, Update update, Class<?> entityClass){
		return mt.updateFirst(query, update, entityClass);
	}
	
	@Override
	public void remove(Query query, Class<?> entityClass){
		mt.remove(query, entityClass);
	}
}
